<?php
namespace app\admin\model;

class News extends Common
{
    protected $autoWriteTimestamp = true;
    protected $auto = ['top', 'recommend','hot'];//模型自动完成
    protected function setTopAttr($top)
    {
        return $top?1:0;
    }
    protected function setRecommendAttr($recommend)
    {
        return $recommend?1:0;
    }
    protected function setHotAttr($hot)
    {
        return $hot?1:0;
    }
    //
    public function tags()
    {
        return $this->belongsToMany('Tags', '\\app\\admin\\model\\NewsTags', 'tags_id','news_id');
    }
    public function newsCategory()
    {
        return $this->belongsTo('NewsCategory', 'news_category_id', 'id');
    }
}